<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>列表渲染</title>
</head>

<body>
    <ul id="example-1">
        <li v-for="item in items">
            {{item.message}}
        </li>
    </ul>
    <ul id="example-2">
        <li v-for="(item,index) in items">
            {{parentMessage}}--{{index}}--{{item.message}}
        </li>
    </ul>
    <ul id="v-for-object" class="demo">
        <li v-for="(value,key,index) in object">
           {{index}}--{{key}}--{{value}}
        </li>
    </ul>
    <script src="https://cdn.jsdelivr.net/npm/vue/dist/vue.js"></script>
    <script>
        var example1 = new Vue({
            el: '#example-1',
            data: {
                items: [{
                        message: 'Foo'
                    },
                    {
                        message: 'Bar'
                    }
                ]
            }
        })
        var example2 = new Vue({
            el: '#example-2',
            data: {
                parentMessage: 'Parent',
                items: [{
                        message: 'Foo'
                    },
                    {
                        message: 'Bar'
                    }
                ]
            }
        })
        new Vue({
            el: '#v-for-object',
            data: {
                object: {
                    firstName: 'John',
                    lastName: 'Doe',
                    age: 30
                }
            }
        })
    </script>
</body>

</html>